<template>
  <div class="container">
    <el-form :model="form" label-width="auto">
      <el-form-item label="商品编号">
        <el-input v-model="form.commodityCode" class="custom-width" />
      </el-form-item>
      <el-form-item label="商品名称">
        <el-input v-model="form.commodityName" class="custom-width" />
      </el-form-item>
      <el-form-item label="商品类型">
        <el-input v-model="form.commodityType" class="custom-width" />
      </el-form-item>
      <el-form-item label="商品地址">
        <el-input v-model="form.commodityPicture" class="custom-width" />
      </el-form-item>
      <el-form-item label="商品原价">
        <el-input v-model="form.originalPrice" class="custom-width" />
      </el-form-item>
      <el-form-item label="商品销售价">
        <el-input v-model="form.price" class="custom-width" />
      </el-form-item>
      <el-form-item label="商品副标题">
        <el-input v-model="form.commoditySubtitle" class="custom-width" />
      </el-form-item>
      <div class="btn-group">
        <el-button class="button-item" type="primary" @click="onSubmit">提交</el-button>
      </div>
    </el-form>
  </div>
</template>

<script lang="ts" setup>
import { createProduct, createOrder } from "../../api/user";
import { reactive, ref, resolveDirective } from "vue";
//切换支付方式
const payType = ref('已支付')
const storeCode = ref('')
const form = reactive({
  commodityCode: "",
  commodityName: "咖啡测试咖啡测试咖啡测试咖啡测试",
  commodityType: "1",
  commodityPicture: "/profile/1.png",
  originalPrice: "24",
  price: "10",
  commoditySubtitle: "咖啡奶香浓郁",
});
const onSubmit = async () => {
  try {
    // const { data } = await createProduct({ ...form });
    // console.log(data.commodityCode, "res");
    // storeCode.value = data.commodityCode;
    const data = {
      "storeId": 121,
      "equipmentId": null,
      "betPrice": 30,
      "inStorageCabinet": 0,
      "commodityList": [
        {
          "num": 1,
          "commodityId": form.commodityCode
        }
      ]
    }
    const res = await createOrder(data)
    console.log(res, 'res')
  } catch (error) {
    console.log(error);
  }
};
</script>

<style scoped lang="scss">
.container {
  .custom-width {
    width: 600px;
  }

  .btn-group {
    display: flex;
    justify-content: center;

    .button-item {
      width: 200px;
    }
  }
}
</style>
